import {fileURLToPath,URL} from 'node:url'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
// import vueJsx from '@vitejs/plugin-vue-jsx'
import Components from 'unplugin-vue-components/vite';

// https://www.antdv.com/docs/vue/introduce-cn#自动按需引入组件
import {AntDesignVueResolver} from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [
    vue(),
    Components({
      resolvers: [
        AntDesignVueResolver({ // 自动按需引入组件
          resolverIcons: true,
          cjs: true,
          importStyle: false, // css in js
        }),
      ],
    }),
  ],
  server: {
    open: true, // 自动打开浏览器
    hmr: true, // 热更新
    port: 8088, //vite项目启动时自定义端口
  },
  define: {
    __APP_VERSION__: JSON.stringify('v1.0.0'),
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),

      '@assets': fileURLToPath(new URL('./src/assets', import.meta.url)),
      '@utils': fileURLToPath(new URL('./src/utils', import.meta.url)),
      '@store': fileURLToPath(new URL('./src/store', import.meta.url)),
      '@storage': fileURLToPath(new URL('./src/store/storage', import.meta.url)),
      '@token': fileURLToPath(new URL('./src/store/storage/token.js', import.meta.url)),
      '@configs': fileURLToPath(new URL('./src/configs', import.meta.url)),
      // '@srv': fileURLToPath(new URL('./src/server', import.meta.url)),

      '@router': fileURLToPath(new URL('./src/router', import.meta.url)),
      '@components': fileURLToPath(new URL('./src/components', import.meta.url)),
      '@views': fileURLToPath(new URL('./src/views', import.meta.url)),
    }
  },
  build: {
    // sourcemap: true, // 开启source map
  }
})